/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import domain.Hall;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import services.impl.HallServices;

/**
 *
 * @author amega
 */
@ManagedBean(name="hallBean")
@SessionScoped
public class HallBean {
    
    @EJB
    private HallServices hallService;
    
    public Hall selectHall;
    
    public Hall newHall = new Hall();
    
    public List<Hall> allHall= new ArrayList<Hall>();
    
    public String[] typeHall = {
        "конференц зал","торжественный зал"
    };

    public String[] getTypeHall() {
        return typeHall;
    }

    public Hall getSelectHall() {
        return selectHall;
    }

    public void setSelectHall(Hall selectHall) {
        this.selectHall = selectHall;
    }

    public Hall getNewHall() {
        return newHall;
    }

    public void setNewHall(Hall newHall) {
        this.newHall = newHall;
    }

    public List<Hall> getAllHall() {
        return allHall;
    }

    public void setAllHall(List<Hall> allHall) {
        this.allHall = allHall;
    }
    
    public void saveHall() {
        hallService.create(newHall);
        newHall = new Hall();
    }
    
    public void deleteHall() {
        hallService.remove(selectHall);
    }
    
    public List<Hall> getAllHalls() {
        allHall = hallService.findAll();
        return  allHall;
    }
}
